#ifndef _OSGIS_STR_UTIL_H_
#define _OSGIS_STR_UTIL_H_

#include <string>
#include <Windows.h>
#include <string>

namespace Osgis
{
	std::wstring Ansi2WChar(LPCSTR pszSrc, int nLen)
	{
		int nSize = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pszSrc, nLen, 0, 0);
		if(nSize <= 0) return NULL;

		WCHAR *pwszDst = new WCHAR[nSize+1];
		if( NULL == pwszDst) return NULL;

		MultiByteToWideChar(CP_ACP, 0,(LPCSTR)pszSrc, nLen, pwszDst, nSize);
		pwszDst[nSize] = 0;

		if( pwszDst[0] == 0xFEFF)                    // skip Oxfeff
			for(int i = 0; i < nSize; i ++) 
				pwszDst[i] = pwszDst[i+1]; 

		std::wstring wcharString(pwszDst);
		delete pwszDst;

		return wcharString;
	}

	std::wstring s2ws(const std::string& s)
	{
		return Ansi2WChar(s.c_str(),s.size());
	}
}
#endif